<%@page import="com.common.util.SN_GUID"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
	//表格动态Id
	request.setAttribute("plugin_id", (int) (Math.random() * 100000));
	request.setAttribute("next_func", request.getParameter("next_func"));
%>
<script type="text/javascript">
function claim_${plugin_id}() {
	var url = '${basePath}page/workflow/api/API/doClaim';
	var data = {
			"act_form_taskId":$("#act_form_taskId").val(),"userId":"${CurrentUserBean.userId}"
			};
	$.ajax({
			type : 'POST' ,
			url : url ,
			data : data ,
			dataType : "json" ,
			async : true ,
			cache : false ,
			jsonpCallback : "jsonpCallback" ,
			success : function(response, status, statusText) {
		//	alert(response + ":" + status + ":" + statusText);
				if(response.status){
					top.query();
					closeWindow_${plugin_id}();
				}else{
					alert(response.content);
				}
			}
	});
	
}
function next_${plugin_id}() {
	var url = '${basePath}page/workflow/api/API/queryTaskByTaskId';
	var data = {
			"act_form_taskId":$("#act_form_taskId").val()
			};
	$.ajax({
			type : 'POST' ,
			url : url ,
			data : data ,
			dataType : "json" ,
			async : true ,
			cache : false ,
			jsonpCallback : "jsonpCallback" ,
			success : function(response, status, statusText) {
		// 		alert(response + ":" + status + ":" + statusText);
				var canSubmit=false;
				if(response.status){
					var data=response.content;
						if(data["assignee"]!=""){
							canSubmit=true;
						}
				}else{
// 						alert(response.content);
					canSubmit=true;
				}
				if($("#comment").val()==""){
					$("#comment").focus();
					alert("请填写-审核意见");
					return ;
				}
				if(canSubmit){
					${next_func eq null?'next':next_func }();
				}else{
					alert("任务无法下一步");
				}
				
			}
	});
	
}
function trace_${plugin_id}(){
	var url = '${basePath}page/workflow/api/API/queryTaskIdByGuid';
	var data = {"act_form_guid":$("#act_form_guid").val()};
	$.ajax({
			type : 'POST' ,
			url : url ,
			data : data ,
			dataType : "json" ,
			async : true ,
			cache : false ,
			jsonpCallback : "jsonpCallback" ,
			success : function(response, status, statusText) {
		// 		alert(response + ":" + status + ":" + statusText);
				if(response.status){
					var data=response.content;
					for(var i=0;i<data.length;i++){
						var m=data[i];
						if(""!=m["processInstanceId"]){
							open("${basePath}page/workflow/trace/TraceManage/toView?processInstanceId="+m["processInstanceId"]);
						}
						return ;
					}
				}
			}
	});
}
function closeWindow_${plugin_id}() {
	parent.w1.close();
}
</script>
<table style="width: 100%;" border="0" cellpadding="0" cellspacing="0">
	<tr>
		<td colspan="2">
			<div>${act_form_guid eq null ?'请在XxxxxxController下增加：String guid=getParam_act_form_guid(request);':''}</div>
			<div>${act_form_taskId eq null ?'请在XxxxxxController下增加：String taskId=getParam_act_form_taskId(request);':''}</div>
			<div>${next_func eq null ?'请在jsp:include下增加：&lt;jsp:param name="next_func" value="next"/&gt;':''}</div>
			<button onclick="claim_${plugin_id}()" class="btn btn-primary" type="button" id="btn_claim" ${act.canClaim?'':'disabled="disabled"' }>
				<span class="glyphicon glyphicon-floppy-disk" aria-hidden="true"></span>
				&nbsp;
				<span>签收</span>
			</button>
			<button onclick="next_${plugin_id}()" class="btn btn-primary" type="button" id="btn_next" ${act.canNext?'':'disabled="disabled"' }>
				<span class="glyphicon glyphicon-floppy-disk" aria-hidden="true"></span>
				&nbsp;
				<span>确认归档</span>
			</button>
			<button onclick="trace_${plugin_id}()" class="btn btn-primary" type="button">
				<span class="glyphicon glyphicon-floppy-disk" aria-hidden="true"></span>
				&nbsp;
				<span>查看流程图</span>
			</button>
			<button onclick="closeWindow_${plugin_id}()" class="btn btn-primary" type="button">
				<span class="glyphicon glyphicon-floppy-disk" aria-hidden="true"></span>
				&nbsp;
				<span>关闭</span>
			</button>
			<input type="hidden" id="act_form_guid" name="act_form_guid" value="${act_form_guid}" style="">
			<input type="hidden" id="act_form_taskId" name="act_form_taskId" value="${act_form_taskId}" style="">
		</td>
	</tr>
	<tr>
		<td style="width: 80px;">审核结果:</td>
		<td>
			<select id="status" name="" value="通过" class="form-control" ${act.canNext?'':'disabled="disabled"' }>
				<option value="true">通过</option>
				<option value="false">不通过</option>
			</select>
		</td>
	</tr>
	<tr>
		<td>审核意见:</td>
		<td>
			<input id="comment" value="" class="form-control" ${act.canNext?'':'disabled="disabled"' }>
		</td>
	</tr>
</table>